<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Car_cate extends Front_Controller {
 	var $siteSetings;
	var $announcement;
	var $lineclass; 
	var $des_tags;		//目的地标签   
	var $carclass;
	function __construct()
	{
		parent::__construct();
		$this->load->helper(array('form'));
		$this->load->model('front/Frontget_ml');
		$this->load->model('front/Search_m');
		$this->load->model('front/Car_cate_m');
		$this->siteSetings=$this->Frontget_ml->get_site_settings();	//获取站点设置
		$this->announcement=$this->Frontget_ml->get_announcement();	//获取网站公告
		$this->lineclass=$this->Frontget_ml->get_lineclass();//获取线路分类
		$this->carclass=$this->Frontget_ml->get_carclass();//获取汽车分类
		$this->newsclass=$this->Frontget_ml->get_newsclass();//获取汽车分类
		$this->des_tags=$this->Search_m->get_des_tags();	//获取网站标签

	}

	public  function car_catelist($cateid){	//旅游线路分类页
		if((int)$cateid){
			$this->load->model('front/Category_m');
				$slider_cars=$this->Car_cate_m->get_slider_cars($cateid);//获取幻灯片
				$friend_links=$this->Frontget_ml->get_friend_links();//获取友情链接
				$commend_cars=$this->Car_cate_m->get_commend_cars($cateid);//获取推荐线路列表
				if(!empty($this->carclass["parentid"][$cateid])){
					$category_list=$this->Car_cate_m->get_category_list($cateid,$this->carclass["parentid"][$cateid]);//获取分类线路列表
				}else{
					$category_list=null;
				}
		//		print_r($category_list);
			$current_title=$this->carclass["classname"][$cateid];
			$data=array("current_title"=>$current_title,"newsclass"=>$this->newsclass,"carclass"=>$this->carclass,"cateid"=>$cateid,"commend_cars"=>$commend_cars,"slider_cars"=>$slider_cars,"des_tags"=>$this->des_tags,"siteSetings"=>$this->siteSetings,"lineclass"=>$this->lineclass,"cateid"=>$cateid,"category_list"=>$category_list,"announcement"=>$this->announcement,"friend_links"=>$friend_links);		
			$this->load->view('inc/header',$data);
			$this->load->view('car_cate_v');
			
		}else{
			redirect(base_url());	//参数错误
		}
	}
	public  function sub_carclass($cateid){	//旅游线路分类页
		if((int)$cateid){
			$slider_cars=$this->Car_cate_m->get_slider_cars($cateid);//获取幻灯片
			$friend_links=$this->Frontget_ml->get_friend_links();//获取友情链接
			$commend_cars=$this->Car_cate_m->get_commend_cars($cateid);//获取推荐线路列表
			//分页
			$this->load->library('pagination');
			$config['base_url'] = site_url('/car_cate/sub_carclass/'.$cateid.'/');
				
			$total_rows= $this->Car_cate_m->get_art_num($cateid);//获取查询条件下的记录总数
			$config['total_rows'] =$total_rows[0];
			//			print_r($config['total_rows']);
			$config['per_page'] = 10;
			$config['uri_segment'] = 4;
			$config['full_tag_open'] = '';
			$config['full_tag_close'] = '';
			$config['cur_tag_open']= '&nbsp;<span class="current">';
			$config['cur_tag_close']= '</span>';
			$config['prev_link']= '上一页';
			$config['next_link']= '下一页';
			$config['first_link']= ' 首页';
			$config['last_link']= ' 尾页';
			//	$config['use_page_numbers'] = TRUE;
			$this->pagination->initialize($config);
			$begin_record=$this->uri->segment(4);
			//分页end
			$subclass_list=$this->Car_cate_m->get_subclass_list($cateid,$begin_record,$config['per_page']);//获取分类线路列表
	
			$current_title=$this->carclass["classname"][$cateid];
			$data=array("current_title"=>$current_title,"newsclass"=>$this->newsclass,"carclass"=>$this->carclass,"cateid"=>$cateid,"commend_cars"=>$commend_cars,"slider_cars"=>$slider_cars,"des_tags"=>$this->des_tags,"siteSetings"=>$this->siteSetings,"lineclass"=>$this->lineclass,"cateid"=>$cateid,"subclass_list"=>$subclass_list,"announcement"=>$this->announcement,"friend_links"=>$friend_links);
			$this->load->view('inc/header',$data);
			$this->load->view('sub_carclass_v');
	
		}else{
			redirect(base_url());	//参数错误
		}
	}	
	public  function car_show($carId){	//获取指定id文章信息
		if((int)$carId){
			$friend_links=$this->Frontget_ml->get_friend_links();//获取友情链接
			$carInfo=$this->Car_cate_m->get_carInfo($carId);	//获取指定id文章信息
			$cateid=explode("-",str_replace(",","",$carInfo['list'][0]->car_class));//文章类id
			//	print_r($cateid);
			//	print_r($lineInfo);
			
			$current_title=$carInfo['list'][0]->car_title;
			$data=array("current_title"=>$current_title,"newsclass"=>$this->newsclass,"carclass"=>$this->carclass,"carId"=>$carId,"des_tags"=>$this->des_tags,"siteSetings"=>$this->siteSetings,"lineclass"=>$this->lineclass,"carInfo"=>$carInfo,"cateid"=>$cateid,"announcement"=>$this->announcement,"friend_links"=>$friend_links);
	
			$this->load->view('inc/header',$data);
			$this->load->view('car_show');
		}else{
			redirect(base_url());	//参数错误
		}
	}	
}